package uiLayer.uiUtilities;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.BoxLayout;

import java.awt.Component;

import javax.swing.Box;

public class AboutDispEasy extends JDialog {

	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			AboutDispEasy dialog = new AboutDispEasy(null);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public AboutDispEasy(JFrame frame) {
		super(frame);
		setModalityType(ModalityType.APPLICATION_MODAL);
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		int width = 220;
		int height = 280;
		int X = (screen.width / 2) - (width / 2); // Center horizontally.
		int Y = (screen.height / 2) - (height / 2); // Center vertically.
		setBounds(X, Y, width, height);
		setTitle("Om DispEasy");
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(15, 25, 15, 15));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
		{
			JLabel lblDispeasy = new JLabel("DispEasy version 1.0");
			contentPanel.add(lblDispeasy);
		}
		{
			JLabel lblDecember = new JLabel("December 2014 ");
			contentPanel.add(lblDecember);
		}
		{
			Component verticalStrut = Box.createVerticalStrut(20);
			contentPanel.add(verticalStrut);
		}
		{
			JLabel lblEksamensprojekt = new JLabel("Eksamensprojekt");
			contentPanel.add(lblEksamensprojekt);
		}
		{
			JLabel lblUdarbejdetAf = new JLabel("udarbejdet af");
			contentPanel.add(lblUdarbejdetAf);
		}
		{
			Component verticalStrut = Box.createVerticalStrut(20);
			contentPanel.add(verticalStrut);
		}
		{
			JLabel lblNewLabel = new JLabel("Bo M. S. Nielsen");
			contentPanel.add(lblNewLabel);
		}
		{
			JLabel lblAndersAPedersen = new JLabel("Anders A. Pedersen");
			contentPanel.add(lblAndersAPedersen);
		}
		{
			JLabel lblMiePlougstrup = new JLabel("Mie Plougstrup");
			contentPanel.add(lblMiePlougstrup);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.setActionCommand("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						closeDialog();
					}
				});
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
				
			}
		}
	}
	
	private void closeDialog() {
		super.setVisible(false);
		super.dispose();
	}

}
